package template

import (
	"math/rand"
	"strconv"
	"utilx/logx"
)

// 实现具体功能接口
//由 作为 OtpMember的 参数进行 统一组装

type SmsMember struct {
	OtpMember
}

func (s *SmsMember) genRandomOTP(len int) string {
	randomOTP := strconv.Itoa(int(rand.Intn(len)))
	logx.Debugf("SMS: generating random OtpArgs %s\n", randomOTP)
	return randomOTP
}

func (s *SmsMember) saveOTPCache(otp string) {
	logx.ErrorLf("SMS: saving OtpArgs: %s to cache\n", otp)
}

func (s *SmsMember) getMessage(otp string) string {
	return "SMS OTP for login is " + otp
}

func (s *SmsMember) sendNotification(message string) error {
	logx.Warnf("SMS: sending sms: %s\n", message)
	return nil
}

//=====

type SmsArgs struct {
	OtpArgs
}

func (s *SmsArgs) genRandomOTP(len int) string {
	randomOTP := strconv.Itoa(int(rand.Intn(len)))

	logx.Debugf("SMS: generating random OtpArgs %s\n", randomOTP)
	return randomOTP
}

func (s *SmsArgs) saveOTPCache(otp string) {
	logx.ErrorLf("SMS: saving OtpArgs: %s to cache\n", otp)
}

func (s *SmsArgs) getMessage(otp string) string {
	return "SMS OTP for login is " + otp
}

func (s *SmsArgs) sendNotification(message string) error {
	logx.Warnf("SMS: sending sms: %s\n", message)
	return nil
}
